{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python \t\t3.6\n",
      "Tensorflow \t1.0.0\n",
      "Keras \t\t2.0.3\n"
     ]
    }
   ],
   "source": [
    "import sys; print('Python \\t\\t{0[0]}.{0[1]}'.format(sys.version_info))\n",
    "import tensorflow as tf; print('Tensorflow \\t{}'.format(tf.__version__))\n",
    "import keras; print('Keras \\t\\t{}'.format(keras.__version__))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline \n",
    "\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting ../mnist-data/train-images-idx3-ubyte.gz\n",
      "Extracting ../mnist-data/train-labels-idx1-ubyte.gz\n",
      "Extracting ../mnist-data/t10k-images-idx3-ubyte.gz\n",
      "Extracting ../mnist-data/t10k-labels-idx1-ubyte.gz\n"
     ]
    }
   ],
   "source": [
    "from tensorflow.examples.tutorials.mnist import input_data\n",
    "mnist = input_data.read_data_sets(\"../mnist-data/\", one_hot=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(55000, 784)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist.train.images.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA2oAAABpCAYAAABLV9A4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xec1MX9x/HXBIMKRiwUTywgNrALYkM0llA0lqgxihEC\nBh8xGCXBFjVRrImgxC62GBV/sUcRu2IhagAVC7agh4iIolGjRhT9/v7gPrOz7N6xtzu7+9279/Px\n8OEwe7c7+75t3535fsYlSYKIiIiIiIikx/eqPQARERERERHJpgM1ERERERGRlNGBmoiIiIiISMro\nQE1ERERERCRldKAmIiIiIiKSMjpQExERERERSRkdqImIiIiIiKRMSQdqzrmBzrnXnXP/ds6dFGtQ\nrZkyjU+ZlodyjU+ZxqdM41Om8SnT+JRpfMq08lyxG14759oAbwB7Ae8C04FDkySZHW94rYsyjU+Z\nlodyjU+ZxqdM41Om8SnT+JRpfMq0OlYo4Xf7Av9OkuQtAOfc/wH7AY3+wTp27Jh069athJtsuWbO\nnLkI2BdlGo0yjW/mzJmLkiTpRDOf/8q0cco0PmUaX7GZgnJtTH19PYsWLXIo06j03h+fMo0veE1t\nUikHal2BecG/3wW2X/aHnHMjgZEA6623HjNmzCjhJlsu59xclGlUyjS+hkyhgFyVaWGUaXzKNL7m\nZNrw88p1Ofr06WNNZRqR3vvjU6bxBa+pTSp7MZEkSSYmSdInSZI+nTot98BRCqBM41Om8SnT+JRp\nfMq0PJRrfMo0PmUanzKNq5QDtfnAusG/12nok+Ip0/iUaXko1/iUaXzKND5lGp8yjU+ZxqdMq6CU\nA7XpwEbOue7OubbAz4C74wyr1VKm8SnT8lCu8SnT+JRpfMo0PmUanzKNT5lWQdHnqCVJssQ5Nwp4\nAGgDXJskySvRRhbRGWec4dvXX389ALfccovvC9aJV1UtZVorlGl5KNf4lGl8yjQ+ZRqfMo1Pmcan\nTKujlGIiJEkyBZgSaSyCMi0HZVoeyjU+ZRqfMo1PmcanTONTpvEp08orezERERERERERaZ6SZtTS\nburUqQBceeWVvq99+/YAWeVC07L0UUREREREBDSjJiIiIiIikjotbkbtv//9r28ffPDBABxxxBG+\n709/+hMAzrnKDkxEas5dd90FwOjRo33fpEmTANhxxx2rMiYRadp3330HwI033uj7Xnklt+bBs88+\n69vbb7903962bdv6Pnvet2nTxvd16NAh7mBbmbvvXlok8NJLL/V9VtxN2Uo5rLfeejl977zzThVG\nUhzNqImIiIiIiKSMDtRERERERERSpsUtfbz88st9e6WVVgJgzJgxvm+FFVrcXa66N954A4ARI0b4\nvrffftu3bfnJxx9/7PvuvfdeAM477zzf16lTp7KOU6S57rjjDgDmzp3r++xxPnv27KqMSaS1C09x\nWLhwIQB/+ctffN9hhx0GwNChQ5u8nh122MG3J06cCEBdXZ3vmzZtGgCzZs3yfccddxwAxx9/vO+z\nzxqS3zPPPOPbw4YNA2CfffbxfSuuuGKlhyStyLx58wBYd911qzyS4mhGTUREREREJGVa3PSSFQsB\nOOqoo4Dsb8gkjldffdW3Bw0aBGSfnJkkiW8PGDAAgI022sj32WzEzJkzfd/DDz8MQMeOHcsw4vSy\nb4TXXHNN32czv4sXL/Z9H3zwQc7vPv7447793HPPNXobV111lW+vvfbaOZf/+c9/BmC//fYrdNit\nwvTp06s9hKr47LPPAPjDH/7g+8IZi6b8+Mc/9u2LL74YgPXXXz/i6KQ1+fzzz33b3jfOPPNM3zd5\n8uSc37nkkksA6Nu3r++zWba33nrL92222Wa+bbNrW265pe974oknADj88MN9n82yLViwwPddcMEF\ngGbWlnXfffcBcMUVV/i+//znPwCstdZavq+15vbRRx8Bmc8+AOPGjQOyt5AK/fa3vwVg/PjxZR5d\nbbMCNZB5btvztDnComFWoND+BpWiGTUREREREZGU0YGaiIiIiIhIyrSYpY92cvHXX3/t+3r27Fmt\n4bRYJ554IgCPPvqo77Mlj127dvV94TK+F198EYAjjzzS99mJ23YZwI9+9CMgs7QEYOWVV4429mqx\n+wrZSxzMY489BmRPsdtSEFsaEf5cKFxi2tTegOHPvfnmmzmX2xKftC99vPXWWwG4+eabfd9ZZ50F\nQK9evSoyBltC1dI89dRTvj1y5EgAXnvtNd+X7/G10047AfD666/7vnApmhURCJebrbLKKpFGXPss\nK3tcQ/Z7mAnzXXXVVYHsJf3nnHMOAN27dy/LOKspLNpje53lEz4+DzjgACB7r65wqV2h+v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NdZjUw7dOjg22effTaQWRIfOvHETP0CWwYZFqGy\nolhhAbCLL74YgB133NH3hUUECl0mHr6eN9eymb7xxhuk8XFqS5DDPezs72GFKyCzNN/er6qhtb2m\nWhGmr776yveFf5MYWkOm8+bNy2mntahIIVUfnwIaK3kW/92hFejXr19OxTPn3KdJknyEMi2KMo1P\nmcanTMtj2Vydc7OTJLFvgZRrEZRpfMtm2qdPH2bMmKFMS6DX1PiUaboU9/WltFjhSen2rWV40qqV\nLp4/f77vs4ILYeGL8Elu31RaoRaAX//610Bps2hpN3bsWACeffZZ3zdgwAAAFixY4Pvsm+B7773X\n933xxRdAdll4m7mETGGWfv36xR52q7fLLrv49qOPPgpkzyBLfEuWLAHgu+8y56vHKNjUUoQFMJ54\n4gkANt10U99X6nYpadGmTRvftvef8D3i7bffBjLbuwBssMEGOT9n70XhY2jFFVcsw4hbJsvK3sMg\n8xgMi6hUcyatNendu7dvT5s2rYojqW077LCDb4efYdNO74QiIiIiIiIpowM1ERERERGRlNHSR2lU\nx44dAZgwYYLvs7YtvwFs086swgvhMkc7GTU8ibs12GSTTYDs5SO2ZCdc0pjPyiuvDGTvaxdeTyl7\nzUnThg0blrctcay11lo5fVOnTgWy9wvacMMNKzWk1Hv55Zd924oIhEsfiy3Ckma2DHLQoEE5lx19\n9NGVHk6rd9FFF1V7CK1W+Fw39vkMYP3116/kcGrW008/Xe0hFEUzaiIiIiIiIinT8r6Gk4ro379/\nTt/AgQOrMJL0uuyyy4BMqWOAe+65B8guu28zb4MHD/Z9Y8aMAaCurq7cwxSpqAsvvBCA+vp639ej\nRw8gveWRq+2FF17I6cs30yQiLc/BBx/s29dccw0AZ511lu/beOONKz4mqRzNqImIiIiIiKSMDtRE\nRERERERSRksfRcqkXbt2AJx++um+L2yLtEYdOnQAMnvUSfNYkZWRI0dWeSQiUglrrrmmb0+fPr2K\nI5Fq0IyaiIiIiIhIymhGTUREJMVGjRqVty0iIi2bZtRERERERERSRgdqIiIiIiIiKeOSJKncjTn3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ZwyBzilkrdd\n4rj7sXR680XghYb/BgNrAo8AbwIPA2tUYWzKVJkq01aYqzJVpspUmSpT5apMW3amrmFAIiIiIiIi\nkhIqJiIiIiIiIpIyOlATERERERFJGR2oiYiIiIiIpIwO1ERERERERFJGB2oiIiIiIiIpowM1ERER\nERGRlNGBmoiIiIiISMr8PzT+1wrcrWcKAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x110ab4b38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(15,5))\n",
    "for i in list(range(10)):\n",
    "    plt.subplot(1, 10, i+1)\n",
    "    pixels = mnist.test.images[i+100]\n",
    "    pixels = pixels.reshape((28, 28))\n",
    "    plt.imshow(pixels, cmap='gray_r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "from keras.models import Sequential\n",
    "from keras.layers.core import Dense, Activation, Dropout"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model = Sequential()\n",
    "model.add(Dense(512, input_shape=(784,)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Dropout(0.25))   \n",
    "model.add(Dense(512, activation='relu'))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Dropout(0.25))   \n",
    "model.add(Dense(10))\n",
    "model.add(Activation('softmax'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 55000 samples, validate on 10000 samples\n",
      "Epoch 1/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0169 - acc: 0.9944 - val_loss: 0.0714 - val_acc: 0.9842\n",
      "Epoch 2/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0132 - acc: 0.9953 - val_loss: 0.0772 - val_acc: 0.9846\n",
      "Epoch 3/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0127 - acc: 0.9955 - val_loss: 0.0760 - val_acc: 0.9819\n",
      "Epoch 4/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0129 - acc: 0.9957 - val_loss: 0.0765 - val_acc: 0.9840\n",
      "Epoch 5/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0128 - acc: 0.9955 - val_loss: 0.0816 - val_acc: 0.9835\n",
      "Epoch 6/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0112 - acc: 0.9961 - val_loss: 0.0744 - val_acc: 0.9831\n",
      "Epoch 7/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0141 - acc: 0.9951 - val_loss: 0.0751 - val_acc: 0.9840\n",
      "Epoch 8/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0129 - acc: 0.9952 - val_loss: 0.0794 - val_acc: 0.9841\n",
      "Epoch 9/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0112 - acc: 0.9965 - val_loss: 0.0782 - val_acc: 0.9838\n",
      "Epoch 10/10\n",
      "55000/55000 [==============================] - 4s - loss: 0.0105 - acc: 0.9964 - val_loss: 0.0818 - val_acc: 0.9833\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x112902da0>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(mnist.train.images, mnist.train.labels,\n",
    "          batch_size=250, epochs=10, verbose=1,\n",
    "          validation_data=(mnist.test.images, mnist.test.labels))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test score: 0.075428174587\n",
      "Test accuracy: 0.979\n"
     ]
    }
   ],
   "source": [
    "score = model.evaluate(mnist.test.images, mnist.test.labels, verbose=0)\n",
    "print('Test score:', score[0])\n",
    "print('Test accuracy:', score[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0: 1.4594842e-06,\n",
       " 1: 4.7986667e-08,\n",
       " 2: 5.683231e-08,\n",
       " 3: 1.2110219e-09,\n",
       " 4: 1.3419144e-07,\n",
       " 5: 3.0428748e-07,\n",
       " 6: 0.99999809,\n",
       " 7: 1.1104975e-09,\n",
       " 8: 3.3768956e-08,\n",
       " 9: 6.2479605e-10}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# test item #100 is a six\n",
    "pixels = mnist.test.images[100]\n",
    "result = model.predict_on_batch(np.array([pixels]))\n",
    "dict(zip(range(10), result[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def test_render(pixels, result, truth):\n",
    "    #pixels, result and truth are np vectors\n",
    "    plt.figure(figsize=(10,5))\n",
    "    plt.subplot(1, 2, 1)\n",
    "    pixels = pixels.reshape((28, 28))\n",
    "    plt.imshow(pixels, cmap='gray_r')\n",
    "\n",
    "    plt.subplot(1, 2, 2)\n",
    "    \n",
    "    #index, witdh\n",
    "    ind = np.arange(len(result))\n",
    "    width = 0.4\n",
    "\n",
    "    plt.barh(ind,result, width, color='gray')\n",
    "    plt.barh(ind+width,truth,width, color='green')\n",
    "    plt.yticks(ind+width, range(10))\n",
    "    plt.margins(y=0)\n",
    "\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlMAAAEyCAYAAADeAVWKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AA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6cZVkHSTzR8RDEfF68eXj\nai1NUydl/g4k6WtqFdl/72S4Esrk/2tJ125bGLdYbqcuyuQPSfsXj/9U0voO5kuKiEck7eiin1mS\nbomWxyW9d8gVzTuNMgUA79je3RmG3m7n7ZmI2CLpFUkHdiRdWpn8g50n6V9GNNHOS/4MxWGZQyLi\n/3QyWEll/g7+TNKf2f6/th+3vaO9KJ1WJv9XJZ1je62keyT9TWeitc3O/u8kqarbyQAAKmT7HEm9\nkv5z1Vl2hu33SPqOpM9VHCXHaLUOMZ2k1p7BR2x/JCJerjRVeXMk3RQR37Z9vKR/tj25WPS3K7Fn\nCgDeUebuDG/P2B6t1mGO33UkXVqpu0vY/qSkv5N0ZkRs7lC2slI/w36SJkt62PYaScdJWlyjk9DL\n/B2slbQ4It6MiH+T9K9qlas6KJP/PLXW0lNEPCZpb7XWCGyKtt+FhTIFAO8oc3eGwSvcnyXpwajP\ngn3J/LaPkXSdWkWqTufqbLPDnyEiXomIsRExKSImqXXe15kR0V9N3P+gzO/QnWrtlZLtsWod9lvd\nyZA7UCb/C5KmS5LtI9UqUwMdTZlnsaS/LK7qO07SK7mLFHOYDwAKEbHF9oWS7tM7d2dYYft/SOqP\niMVq3Y7nn20/p9ZJrrOrS/xuJfN/S9K+km4vzpt/ISLOrCz0ECV/htoqmf8+SafaXilpq6T/HhG1\n2LtZMv+lkq63fYlaJ6N/rkb/oHjXHTWK87rmStpDkiLif6l1ntfpkp6T9Lqkv8p+zRr9/AAAAI3D\nYT4AAIAMlCkAAIAMlCkAAIAMlCkAAIAMlCkAAIAMlCkAAIAMlCkAAIAM/x880ddhpRIBTgAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1102efda0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import random\n",
    "i = random.randint(0,mnist.test.images.shape[0])\n",
    "\n",
    "pixels = mnist.test.images[i]\n",
    "truth  = mnist.test.labels[i]\n",
    "result = model.predict_on_batch(np.array([pixels]))[0]\n",
    "\n",
    "test_render(pixels, result, truth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "### What went wrong?\n",
    "pixels = mnist.test.images\n",
    "result = model.predict_on_batch([pixels])\n",
    "truth = mnist.test.labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Incorrect predictions: 210\n"
     ]
    }
   ],
   "source": [
    "acc = result.argmax(axis=1) == truth.argmax(axis=1)\n",
    "incorrect = np.argwhere(acc==False).flatten()\n",
    "\n",
    "print(\"Incorrect predictions: {}\".format(len(incorrect)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABIEAAABdCAYAAAAyhXaGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xm4G3X1x/H3QFtBKXtBKHsFRCoUKCBSENkXrci+yC4U\nEGgFhAr8FAREhbJvgiKryKoFRfZ9tQurQEupZbNUytbWgoDO74/eT76TuTP35t6b3EySz+t5+tw2\nyU0mpyeTZL5nzoniOMbMzMzMzMzMzJrbfPXeADMzMzMzMzMzqz0fBDIzMzMzMzMzawE+CGRmZmZm\nZmZm1gJ8EMjMzMzMzMzMrAX4IJCZmZmZmZmZWQvwQSAzMzMzMzMzsxbgg0BmZmZmZmZmZi2gRweB\noijaNoqiSVEUTYmiaHS1NqoZODbZHJd8jk02xyWfY5PNccnn2GRzXPI5Ntkcl3yOTTbHJZvjks+x\nyea49FwUx3H3fjGK5gcmA1sBbwLjgD3jOH6xepvXmBybbI5LPscmm+OSz7HJ5rjkc2yyOS75HJts\njks+xyab45LNccnn2GRzXKqjJweBNgJOjuN4m7Z//xggjuMz8n5nySWXjFdaaaVuPV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k6m3DgINBN5I/PtNqvOfWjdRFK0ErAM81XbREVEUPRdF0RVRFC3Whbtqqtg4\nLvkcm2yOSz7HJpvjks+xyea45HNssjku+RybbI5LPscmm+OSrYpxAccmkxtDd0MURQsBtwCj4jie\nBVwCDAKGANOBMXXcvLpxXPI5Ntkcl3yOTTbHJZ9jk81xyefYZHNc8jk22RyXfI5NNsclm+OSr5qx\n6a2DQG8Byyf+vVzbZQ0niqK+zAv+dXEc3woQx/GMOI7/G8fx/4DLmVd2VqmmiI3jks+xyea45HNs\nsjku+RybbI5LPscmm+OSz7HJ5rjkc2yyOS7ZahAXcGwy9dZBoHHAqlEUrRxFUT9gD+C2Xnrsqomi\nKAJ+C7wUx/HZicuXSdzsu8ALXbjbho+N45LPscnmuORzbLI5Lvkcm2yOSz7HJpvjks+xyea45HNs\nsjku2WoUF3BsMvWp3ubli+P4syiKjgDuYl6H7iviOP57bzx2lW0M7AM8H0XRM22XnQDsGUXRECAG\npgEjKr3DJomN45LPscnmuORzbLI5Lvkcm2yOSz7HJpvjks+xyea45HNssjku2aoeF3Bs8kTxvFFj\nZmZmZmZmZmbWxNwY2szMzMzMzMysBfggkJmZmZmZmZlZC/BBIDMzMzMzMzOzFuCDQGZmZmZmZmZm\nLcAHgczMzMzMzMzMWoAPApmZmZmZmZmZtQAfBDIzMzMzMzMzawE+CGRmZmZmZmZm1gL+Hw+oQJ31\nN66FAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x112a17400>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,5))\n",
    "plt_idx = 1\n",
    "for i in list(incorrect[:16]):\n",
    "    plt.subplot(1, 16, plt_idx)\n",
    "    pixels = mnist.test.images[i]\n",
    "    pixels = pixels.reshape((28, 28))\n",
    "    plt.imshow(pixels, cmap='gray_r')\n",
    "    plt_idx += 1\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlMAAAEyCAYAAADeAVWKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGx1JREFUeJzt3X+QXXWd5vHnMYQFIpJA2lRCEpJVRodl18BeY2YDLBpD\nJSwmsDuFUOUMTlHTFgUIbGpXcNeK0drSURJntoqNicqQyQrqKAwpFgQF3CwRkW7IQkIEWSaR/G5W\nkIjuQOCzf9wTaHrSfU7yvX3POTnvV1VX3x+f9H3uTWwfzo/vcUQIAAAAh+cdZQcAAACoM8oUAABA\nAsoUAABAAsoUAABAAsoUAABAAsoUAABAAsoUAABAAsoUAABAAsoUAABAgqPKDgAAdTBx4sSYMWNG\n2TEAdFF/f/8LEdGTN0eZAoACZsyYob6+vrJjAOgi29uKzLGbD0Bj2b7G9ibbm21fW3YeAPVEmQLQ\nSLZPl/TnkmZL+oCkC2y/t9xUAOqIMgWgqf5Q0iMR8buI2C/pf0r6tyVnAlBDlCkATbVJ0tm2T7J9\nnKTzJU0rOROAGuIAdACNFBFbbP+FpPskvSJpo6TXB8/Y7pXUK0nTp0/vekYA9cCWKQCNFRHfioh/\nGRHnSHpR0jNDnl8dEa2IaPX05J4dDaCh2DIFoLFsvzsi9tqervbxUnPKzgSgfrpaplj0Dmieoove\nleQHtk+S9JqkKyPipbIDAaifpDJle4Gkv5I0RtI3I+LLI82z6B3QPEUXvStDRJxddgYA9XfYZcr2\nGEk3SZovabukR22vi4inOhUOAKpi586dWrZsWdkxAAyxdOnSsiMkHYA+W9KzEfFcRLwq6TuSFncm\nFgAAQD2klKmTJT0/6P727DEAAIDGGPWlEWz32u6z3TcwMDDaLwcAANBVKWVqh96+WvDU7LG3YZ0W\nAABwJEspU49KOtX2TNtHS7pE0rrOxAIAAKiHwz6bLyL2275K0r1qL41wc0Rs7lgyAACAGkhaZyoi\n7pZ0d4eyAAAA1A7X5gMAAEhAmQIAAEhAmQIAA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ko6NfvqVXtpmCSUKQB4y5tXZ4iIVyUduDrDYIvVXtleapeR\nedlZklWQmz8iHoyI32V3f6b20jRVUuTvQJK+qHaR/X/dDFdAkfx/LummAwvjZsvtVEWR/CHpXdnt\nEyTt7GK+XBGxXtJIJ/0slvQ30fYzSeOHnNF8yChTAPCWg12dYejldt6ciYj9kn4j6aSupMtXJP9g\nl0u6Z1QTHbrc95DtlpkWEf+jm8EKKvJ38AeS/sD2Bts/sz3SVpRuK5L/85I+YXu7pLslXd2daB1z\nqP87yVXW5WQAACWy/QlJLUn/uuwsh8L2OyStkPTJkqOkOErtXUznqr1lcL3tfx4RL5WaqrhLJd0S\nEctt/5GktbZPzxb9bSS2TAHAW4pcneHNGdtHqb2b4/92JV2+QleXsP1RSf9J0qKI+IcuZSsq7z0c\nL+l0ST+xvVXSHEnrKnQQepG/g+2S1kXEaxHx95KeUbtcVUGR/JervZaeIuJhSceovUZgXXT8KiyU\nKQB4S5GrMwxe4f6PJT0Q1VmwLze/7TMkrVK7SFXpWJ0DRnwPEfGbiJgYETMiYobax30tioi+cuL+\nI0X+Df2d2lulZHui2rv9nutmyBEUyf8rSfMkyfYfql2mBrqaMs06SX+andU3R9JvUhcpZjcfAGQi\nYr/tqyTdq7euzrDZ9hck9UXEOrUvx7PW9rNqH+R6SXmJ365g/q9Keqekv82Om/9VRCwqLfQQBd9D\nZRXMf6+k82w/Jel1Sf8hIiqxdbNg/iWSvmH7OrUPRv9khf6D4m1X1MiO61oqaawkRcTX1T7O63xJ\nz0r6naQ/S37NCr1/AACA2mE3HwAAQALKFAAAQALKFAAAQALKFAAAQALKFAAAQALKFAAAQALKFAAA\nQIL/D3+YA8hE1ruOAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x119283dd8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "i = random.choice(list(incorrect))\n",
    "\n",
    "pixels = mnist.test.images[i]\n",
    "truth  = mnist.test.labels[i]\n",
    "result = model.predict_on_batch(np.array([pixels]))[0]\n",
    "\n",
    "test_render(pixels, result, truth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
